﻿using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web.Services;
using cde.SystemCommon;
using Cit.CDE.Net.Module;
using Cit.CDE.Net.Module.Commons;
using Cit.CDE.Net.Service.ModuleFactory;
using Module;
using System;
using System.Data;

/// <summary>
/// Copyright (C)   北京世纪思特技术开发有限公司
/// FileName:        SystemWS.cs
/// Author :         Wangbc
/// CDT:             2013-09-16           
/// Version:         1.0.0.0                
/// Depiction:       System WebService接口
/// </summary>
[WebService(Namespace = "SystemServer")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SystemWS : System.Web.Services.WebService
{
    /// <summary>
    /// WS工具类
    /// </summary>
    private WSUtil wsUtil = new WSUtil();

    /// <summary>
    /// 初始化
    /// </summary>
    public SystemWS()
    {

    }

    [WebMethod(Description = "查询系统数据")]
    public DataTable GetDataTable(string lickey, string sql)
    {
        DataTable dt = new DataTable();
        //授权码检查
        string key = wsUtil.ChkLicKey(lickey);
        if (!key.Equals(wsUtil.LICKEY_OK))
        {
            return null;
        }
        else
        {
            // 验证参数是否为string.Empty
            if (sql == null || sql == string.Empty)
            {
                return null;
            }
            dt=Util.loadSql(sql);

            return dt;
        }
    }


    [WebMethod(Description = "更新系统数据")]
    public string UpdateSql(string lickey, string sql)
    { 
        //授权码检查      
        string key = wsUtil.ChkLicKey(lickey);
        if (!key.Equals(wsUtil.LICKEY_OK))
        {
            return key;
        }
        else
        {
            // 验证参数是否为string.Empty
            if (sql == null || sql == string.Empty)
            {

                return wsUtil.getErrMessage("03");
            }

            return Util.objectToString(Util.ExcSql(sql)); 
           
        }
    }

}

